import axios from 'axios'
import qs from "qs";

// 创建自定义的axios对象
const myAxios = axios.create({
  timeout: 100000,
  headers:{
    "Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"
  }
})

// 添加请求拦截器
myAxios.interceptors.request.use(function (config) {
  // 在发送请求之前做些什么：携带其他数据，解析数据，规范化数据
  config.data = qs.stringify(config.data);
  return config;
}, function (error) {
  // 对请求错误做些什么
  return Promise.reject(error);
});

// 添加响应拦截器
myAxios.interceptors.response.use(function (response) {
  // 对响应数据做点什么：提前对响应到的数据，进行统一的处理，或进行前端的权限验证，或登录验证
  return response;
}, function (error) {
  // 对响应错误做点什么
  return Promise.reject(error);
});

export function getNavData(){
  return new Promise(resolve=>{
      resolve({  
		  data:[{
		      title:"IT·互联网",
		      href:"/kind",
			  id:1,
			  sort:["前端开发","Java"],
			  sec:[{
				title:"前沿技术",
				type:["云计算","云原生","区块链","物联网","5G","VR/AR","量子计算"]
			  },{
				title:"环境艺术设计",
				type:["室内设计","建筑设计","景观设计","设计软件","其他"]
			  },{
				title:"Java开发",
				type:["Java零基础","Java进阶"]
			  },{
				title:"互联网产品",
				type:["产品经理","游戏策划"]
			  },{
				title:"后台开发",
				type:["C/C++","Go","C#/.Net","PHP","其他"]
			  }
			]
		    },{
		      title:"设计·创作",
		      href:"/kind",
			  id:2,
			  sort:["平面设计","室内设计","绘画创作"],
			  sec:[{
				title:"Python",
				type:["数据爬虫","办公自动化","Python开发","Python其他应用"]
			  },{
				title:"前端开发",
				type:["前端零基础","前端进阶","其他"]
			  },{
				title:"移动开发",
				type:["iOS","Android","鸿蒙OS","其他"]
			  },{
				title:"大数据与AI",
				type:["数据分析","大数据","机器学习","计算机视觉","自然语言处理(NLP)","人工智能","其他"]
			  },{
				title:"软件测试",
				type:["功能测试","自动化测试","性能测试","安全测试","接口测试","测试开发","其他"]
			  },{
				title:"运维",
				type:["Linux运维","自动化运维","DevOps","K8S","安全","其他"]
			  }]
		    },{
		      title:"考试·考证",
		      href:"/kind",
			  id:3,
			  sort:["公务员","教师考试","建筑工程"],
			  sec:[{
				title:"前沿技术",
				type:["云计算","云原生","区块链","物联网","5G","VR/AR","量子计算"]
			  },{
				title:"环境艺术设计",
				type:["室内设计","建筑设计","景观设计","设计软件","其他"]
			  },{
				title:"Java开发",
				type:["Java零基础","Java进阶"]
			  },{
				title:"互联网产品",
				type:["产品经理","游戏策划"]
			  },{
				title:"后台开发",
				type:["C/C++","Go","C#/.Net","PHP","其他"]
			  }
			]
		    },{
		      title:"电商·营销",
		      href:"/kind",
			  id:4,
			  sort:["电商平台","跨境电商","直播电商"],
			  sec:[{
				title:"Python",
				type:["数据爬虫","办公自动化","Python开发","Python其他应用"]
			  },{
				title:"前端开发",
				type:["前端零基础","前端进阶","其他"]
			  },{
				title:"移动开发",
				type:["iOS","Android","鸿蒙OS","其他"]
			  },{
				title:"大数据与AI",
				type:["数据分析","大数据","机器学习","计算机视觉","自然语言处理(NLP)","人工智能","其他"]
			  },{
				title:"软件测试",
				type:["功能测试","自动化测试","性能测试","安全测试","接口测试","测试开发","其他"]
			  },{
				title:"运维",
				type:["Linux运维","自动化运维","DevOps","K8S","安全","其他"]
			  }]
		    },{
		      title:"职业·职场",
		      href:"/kind",
			  id:5,
			  sort:["技能职工","职业素养"],
			  sec:[{
				title:"前沿技术",
				type:["云计算","云原生","区块链","物联网","5G","VR/AR","量子计算"]
			  },{
				title:"环境艺术设计",
				type:["室内设计","建筑设计","景观设计","设计软件","其他"]
			  },{
				title:"Java开发",
				type:["Java零基础","Java进阶"]
			  },{
				title:"互联网产品",
				type:["产品经理","游戏策划"]
			  },{
				title:"后台开发",
				type:["C/C++","Go","C#/.Net","PHP","其他"]
			  }
			]
		    },{

				
		      title:"兴趣·生活",
		      href:"/kind",
			  id:6,
			  sort:["乐器演奏","美妆"],
			  sec:[{
				title:"Python",
				type:["数据爬虫","办公自动化","Python开发","Python其他应用"]
			  },{
				title:"前端开发",
				type:["前端零基础","前端进阶","其他"]
			  },{
				title:"移动开发",
				type:["iOS","Android","鸿蒙OS","其他"]
			  },{
				title:"大数据与AI",
				type:["数据分析","大数据","机器学习","计算机视觉","自然语言处理(NLP)","人工智能","其他"]
			  },{
				title:"软件测试",
				type:["功能测试","自动化测试","性能测试","安全测试","接口测试","测试开发","其他"]
			  },{
				title:"运维",
				type:["Linux运维","自动化运维","DevOps","K8S","安全","其他"]
			  }]
		    },{
		      title:"语言·留学",
		      href:"/kind",
			  id:7,
			  sort:["实用英语","雅思","托福"],
			  sec:[{
				title:"前沿技术",
				type:["云计算","云原生","区块链","物联网","5G","VR/AR","量子计算"]
			  },{
				title:"环境艺术设计",
				type:["室内设计","建筑设计","景观设计","设计软件","其他"]
			  },{
				title:"Java开发",
				type:["Java零基础","Java进阶"]
			  },{
				title:"互联网产品",
				type:["产品经理","游戏策划"]
			  },{
				title:"后台开发",
				type:["C/C++","Go","C#/.Net","PHP","其他"]
			  }
			]
		    },{
		      title:"企业·培训",
		      href:"/kind",
			  id:8,
			  sort:["组织管理","岗位技能","职场通用"],
			  sec:[{
				title:"Python",
				type:["数据爬虫","办公自动化","Python开发","Python其他应用"]
			  },{
				title:"前端开发",
				type:["前端零基础","前端进阶","其他"]
			  },{
				title:"移动开发",
				type:["iOS","Android","鸿蒙OS","其他"]
			  },{
				title:"大数据与AI",
				type:["数据分析","大数据","机器学习","计算机视觉","自然语言处理(NLP)","人工智能","其他"]
			  },{
				title:"软件测试",
				type:["功能测试","自动化测试","性能测试","安全测试","接口测试","测试开发","其他"]
			  },{
				title:"运维",
				type:["Linux运维","自动化运维","DevOps","K8S","安全","其他"]
			  }]
		    }]
      })
  })
}
export function getHomeNav(){
	return new Promise(resolve=>{
		resolve({data: [{
			id: '1',
			title: '推荐精选',
			href: 'homedetail'
		}, {
			id: '2',
			title: 'java开发',
			href: 'homedetail'
		}, {
			id: '3',
			title: '平面设计',
			href: 'homedetail'
		}, {
			id: '4',
			title: '英语',
			href: 'homedetail'
		}],
		})
	})
}

export function getHotData(){
	return new Promise(resolve=>{
		resolve({data: [{                     //底部一级导航
			id: 1,
			title: 'IT.互联网',
			href: 'hotdetail'
		}, {
			id: 2,
			title: '设计.创作',
			href: 'hotdetail'
		}, {
			id: 3,
			title: '考试.考证',
			href: 'hotdetail'
		}, {
			id: 4,
			title: '电商.营销',
			href: 'hotdetail'
		}, {
			id: 5,
			title: '职业.职场',
			href: 'hotdetail'
		}, {
			id: 6,
			title: '兴趣.生活',
			href: 'hotdetail'
		}, {
			id: 7,
			title: '语言.留学',
			href: 'hotdetail'
		}, {
			id: 8,
			title: '企业.培训',
			href: 'hotdetail'
		},
		]})
	})
}

export function getBannerData(){
	return new Promise(resolve=>{
		resolve({ data: [{
				img: 'https://gdhrss-1251316161.cos.ap-guangzhou.myqcloud.com/public/93310037bac05d57466a07e2e0f14dd8e79c55cc1654655975805/04f5f278-8c7f-4003-ad77-422b673e1cc1.jpg',
				href: ''
			},
			{
				img: 'https://gdhrss-1251316161.cos.ap-guangzhou.myqcloud.com/public/93310037bac05d57466a07e2e0f14dd8e79c55cc1654655975805/04f5f278-8c7f-4003-ad77-422b673e1cc1.jpg',
				href: ''
			}, {
				img: 'https://gdhrss-1251316161.cos.ap-guangzhou.myqcloud.com/public/93310037bac05d57466a07e2e0f14dd8e79c55cc1654655975805/04f5f278-8c7f-4003-ad77-422b673e1cc1.jpg',
				href: ''
			}],})
	})
}

export function getVideoData(){
	return new Promise(resolve=>{
		resolve({ data:[{
			img:'https://10.idqqimg.com/qqcourse_logo_ng/ajNVdqHZLLDaRTUFiciaoUz5Wvp5PE4hGsZWvsaibaCA0hXrEcwxrWOdKJkUWq8OacwrdCs50tyYias/510',
			title:'这些算法年年都出现，看看自己会做吗'
		},{
			img:'https://10.idqqimg.com/qqcourse_logo_ng/ajNVdqHZLLAxZy3jF4yjsUV0ety7qV4Vianmabz1fGH12dWMgiaYnElrDRdeUBoRNYibOLfaWlIB6E/510',
			title:'新手必听课，PS到底怎么P？新手入门教学'
		},{
			img:'https://10.idqqimg.com/qqcourse_logo_ng/ajNVdqHZLLB0MyHQS0QrvUugEtVV332T795Dpfs2ITbYJK7z4Pv4XiceMkK1OHY1fuwm53c3xOGk/510',
			title:'【lucy老师】零基础英语.易错音精讲'
		}]})
	})
}

export function getlistData(){
	return myAxios({
		url:"/api/api/listData"
	})
}

export function getHot() {
	return new Promise(resolve => {
		resolve({
			data: [{
				title: "课程表",
				href: "/hot/01",
				name: "hot01"
				// id:"plan"
			}, {
				title: "畅学卡",
				href: "/hot/02",
				name: "hot02"
			}, {
				title: "订单管理",
				href: "/hot/03",
				name: "hot03"
			},{
				title: "分期付款",
				href: "/hot/04",
				name: "hot04"
			}, {
				title: "收藏",
				href: "/hot/05",
				name: "hot05"
			}, {
				title: "优惠券",
				href: "/hot/06",
				name: "hot06"
			},  {
				title: "我的余额",
				href: "/hot/07",
				name: "hot07"
			},{
				title: "课程分销",
				href: "/hot/08",
				name: "hot08"
			}, {
				title: "个人信息",
				href: "/hot/09",
				name: "hot09"
			}, {
				title: "帐号与安全",
				href: "/hot/10",
				name: "hot10"
			}, {
				title: "课程兑换",
				href: "/hot/11",
				name: "hot11"
			}
			]
		})
	})
}
export function useUser(type, d){
	return myAxios({
	  url: `/abi/user/${type}`,
	  method: "post",
	  data: d
	})
  }
export function titleData(){
	return axios({
		url:"/abi/tree/json"
	})
}
export function getHotNav(){
	return myAxios({
	  url:`/abi/tree/json`,
	})
  }
export function get(){
	return myAxios({
	  url:'/api/api/listData'
	})
  }
  

 

export function getAlldata(){
	 return myAxios({
		url:`/api/api/listData`
	 })
}

export function logout(){
	return myAxios({
		url:`/api/user/logout/json`
	})
}
